$(document).ready(function() {

$('body').css('display', 'none');

$('body').fadeIn(1000);



$('.link').click(function(event) {

event.preventDefault();

newLocation = this.href;

$('body').fadeOut(1000, newpage);

});



function newpage() {

window.location = newLocation;

}

});

// image preloader
$(document).ready(function(e) {  
 $('img').css('opacity',0); // hide all images  
});  
$(window).load(function() { // we use $(window).load because unlike $(document).ready, it isn't triggered until the client has finished loading completely.  
 $('img').animate({'opacity':1},800); // everything is loaded, fade images in  
}); 



// bg preloader
    (function($) {
    function parseImagesFromCSS(doc) {
    var i, j,
    rule,
    image,
    pattern = /url\((.*)\)/,
    properties = ['background-image', '-webkit-border-image'],
    images = {};
     
    if (doc.styleSheets) {
    for (i = 0; i < doc.styleSheets.length; ++i) {
    images = $.extend(images, parseImagesFromCSS(doc.styleSheets[i]));
    }
    } else if (doc.cssRules) {
    for (i = 0; i < doc.cssRules.length; ++i) {
    rule = doc.cssRules[i];
    if (rule.styleSheet) {
    images = $.extend(images, parseImagesFromCSS(rule.styleSheet));
    } else if (rule.style) {
    for (j=0; j < properties.length; j++) {
    image = pattern.exec(rule.style.getPropertyValue(properties[j]));
    if (image && image.length === 2) {
    images[image[1]] = image[0];
    }
    }
    }
    }
    }
    return images;
    };
    $.extend({
    preload: {
    images: function(doc) {
    doc = doc || document;
    var images = $.map(parseImagesFromCSS(doc), function(url) { return url; }),
    head = doc.getElementsByTagName('head')[0],
    style = doc.createElement('style');
    style.type = 'text/css';
    style.id = 'preload';
    style.innerHTML = 'body::after { content: ' + images.join(' ') + '; display: none; }';
    head.appendChild(style);
    }
    }
    });
    })(jQuery);